package org.apache.el.parser;

import javax.el.ELException;

import org.apache.el.lang.EvaluationContext;

/**
 * 
 * 
 * @author 代波
 * @since 2011-8-20
 */
public final class AstCompositeExpression extends SimpleNode {
	public AstCompositeExpression(int id) {
		super(id);
	}

	public Class<?> getType(EvaluationContext ctx) throws ELException {
		Class<?> obj = null;
		if (this.children != null) {
			for (int i = 0; i < this.children.length; i++) {
				obj = this.children[i].getType(ctx);
				if (obj != null) {
					return obj;
				}
			}
		}
		return obj;
	}

	public Object getValue(EvaluationContext ctx) throws ELException {
		Object obj = null;
		if (this.children != null) {
			for (int i = 0; i < this.children.length; i++) {
				obj = this.children[i].getValue(ctx);
				if (obj != null) {
					return obj;
				}
			}
		}
		return obj;
	}

	@Override
	public boolean isReadOnly(EvaluationContext ctx) throws ELException {
		// TODO Auto-generated method stub
		return super.isReadOnly(ctx);
	}

	@Override
	public void setValue(EvaluationContext ctx, Object value) throws ELException {
		if (this.children != null) {
			for (int i = 0; i < this.children.length; i++) {
				this.children[i].setValue(ctx, value);
			}
		}
	}
}
